import { useState } from "react";

function useUserManagement(){
  const [users, setUsers] = useState();
  function addUser(use){
    setUsers([...users, use])
  }
  function deleleUser(useId){
    setUsers( users.filter(user => user.id !== useId ) )
  }

  return [ users, addUser, deleleUser ];
}

const UserTabel = ({ user, onDelete }) => { 
  return(
    <table>
      <thead>
        <tr>
          <td>姓名</td>
          <td>操作</td>
        </tr>
      </thead>
      <tbody>
        {
          user.map(use => {
            <tr key={use.id}>
              <td>{use.name}</td>
              <td><button onClick={() => {}}>delete</button></td>
            </tr>
          })
        }
      </tbody>
    </table>
  )
}
